<?php

#    Document   : upload
#    Created on : May 6, 2011, 12:46:04 PM
#    Author     : ClarkT AKA FalleN
#    Company    : Amodity
#    Web        : http://www.amodity.com
#    Copyright  : 2011
/**

 * @property CI_Loader $load

 * @property CI_Form_validation $form_validation

 * @property CI_Input $input

 * @property CI_Email $email

 * @property CI_DB_active_record $db

 * @property CI_DB_forge $dbforge

 *  @property CI_Session $session

 * @property CI_FTP $ftp

 */

class Upload extends CI_Controller {

    //vars for uploadify script. I'm setting up multiple instances of the class here, I wouldn't copy that
    //method, this is only for demonstration purposes. For multiple upload forms you can use a single class.
    var $uploadify_rules = array(
        'ids' => 'upload',
        'documentReady' => FALSE,
        'uploader' => 'assets/uploadify/uploadify.swf',
        'script' => 'assets/uploadify/uploadify.php',
        'cancelImg' => 'assets/uploadify/cancel.png',
        'folder' => 'uploads',
        'returnFunction' => 'upload/image_return',
        'saveFunction' => 'upload/save_image',
        'cancelFunction' => 'upload/cancel_crop',
        'imageWidth' => 50,
        'imageHeight' => 50,
        'thumbHeight' => 100,
        'thumbWidth' => 100,
    );
    
    var $upload = '';

    public function __construct() {
        parent::__construct();
        $this->load->library('uploadify_max', $this->uploadify_rules);
        $this->upload = new Uploadify_max($this->uploadify_rules);
        $this->load->helper('html');
    }

    function index() {
        $this->template->set('title', lang('g_upload'));
        $this->template->set('head', "jQuery(document).ready(function() {" . $this->upload->get_head() . "});");
        $this->template->load('site_template', 'upload/upload_form');
    }

    function image_return() {

        $this->uploadify_max->get_image_return($_POST);
    }

    function save_image() {

        $this->uploadify_max->process_image($_POST);
    }

    function cancel_crop() {

        $this->uploadify_max->cancel_crop($_POST);
    }

}

?>
